The present invention relates to data processing by digital computer, and more particularly to identifying unnecessary synchronization objects in software applications via runtime analysis.
In multi-threaded software applications, the problem of coordinating multiple threads or processes to share data or resources often arises. For example, when one process or thread is writing data to a memory location, other processes or threads may need to be prevented from writing to the same memory location at the same time in order to prevent data corruption from occurring. Also, processes or threads may need to be prevented from reading from the memory location while it is being written to, in order to ensure that partial or incorrect data is not read.
Software developers generally prefer to not utilize large numbers of synchronization objects (e.g., locks) in the development of multi-threaded application programs. Some software developers suggest using one common interface for protecting access to resources that are shared between a given application program's threads, i.e., a single common lock for use everywhere in an application. Although use of a common synchronization interface throughout a complex software application is not always practical, the introduction of additional methods of protecting access to shared resources can lead to pitfalls, including, for example, poor performance, race conditions, and deadlocks. For example, a multi-threaded software application running on a multiprocessor system may perform poorly when individual threads of the program protect a resource and thereby prevent other threads using that resource from operating, thus allowing one or more processors to idle while useful computations could have occurred. While performance bottlenecks are bad, the problems created by race conditions and deadlocks are typically even worse.
Thus if protection of a resource is unnecessary (i.e., unsuitable) during execution (e.g., because only one thread accesses the protected resource, or because the resource has existing protection that is unnecessarily augmented by the use of additional protection), then the software developer would be wise to remedy the situation. In some circumstances, the entire set of resources associated with a particular synchronization object receives adequate protection from additional synchronization objects, whenever those resources are accessed as the software application runs. In some other circumstances, the entire set of resources protected by a synchronization object needs no protection because only one thread accesses those resources as the software application runs. A straightforward way to remedy either of these situations is to altogether remove extraneous synchronization objects. For this reason, the software developer would benefit from a means of identifying any synchronization objects that can be determined to be unnecessary as the software application runs.